package com.zzl.alligator.management.system.service.impl;


import com.zzl.alligator.common.util.SpringUtils;
import com.zzl.alligator.management.system.domain.SysPost;
import com.zzl.alligator.management.system.mapper.SysPostMapper;
import com.zzl.alligator.management.system.service.ISysPostService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
/**
 * 岗位信息表(SysPost)服务层
 *
 * @author zhouziliang
 * @since 2020-07-01
 */
@Service
public class SysPostService implements ISysPostService {
    
    @Autowired
    private SysPostMapper sysPostMapper;
    
    /**
     * 通过ID查询单条数据
     *
     * @param postId 主键
     * @return 实例对象
     */
    @Override
    public SysPost findSysPostById(Long postId) {
        return sysPostMapper.selectPostById(postId);
    }

    /**
     * 查询所有岗位信息
     *
     * @return 岗位列表
     */
    @Override
    public List<SysPost> fndAllPost() {
        return SpringUtils.getAopProxy(this).findSysPostList(new SysPost());
    }

    /**
     * 根据用户id查找岗位信息
     *
     * @param userId 用户ID
     * @return 岗位列表
     */
    @Override
    public List<Long> findPostListByUserId(Long userId) {
        return sysPostMapper.selectPostListByUserId(userId);
    }

    /**
     * 通过实体作为筛选条件查询
     *
     * @param sysPost 实例对象
     * @return 对象列表
     */
    @Override
    public List<SysPost> findSysPostList(SysPost sysPost) {
        return sysPostMapper.selectPostList(sysPost);
    }

    /**
     * 新增数据
     *
     * @param sysPost 实例对象
     * @return 实例对象
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int insertSysPost(SysPost sysPost) {
        return sysPostMapper.insertPost(sysPost);
    }

    /**
     * 修改数据
     *
     * @param sysPost 实例对象
     * @return 实例对象
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int updateSysPost(SysPost sysPost) {
        return sysPostMapper.updatePost(sysPost);
    }

    /**
     * 通过主键删除数据
     *
     * @param postId 主键
     * @return 是否成功
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean deleteById(Long postId) {
        return sysPostMapper.deletePostById(postId) > 0;
    }


    
}